package com.alibaba.algo.cooperation.feign.service;

import com.alibaba.algo.cooperation.common.BaseResult;
import com.alibaba.algo.cooperation.common.PagerEntity;
import com.alibaba.algo.cooperation.feign.config.FeignConfiguration;
import com.alibaba.algo.cooperation.feign.vo.req.*;
import com.alibaba.algo.cooperation.feign.vo.res.*;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;
import java.util.Map;

/**
 * @author Fan.tianpeng
 * @date 2021/5/8 14:39
 */
@FeignClient(url="${feign.userCenterUrl:}", value = "usercenter-service", contextId = "usercenter-role", configuration = FeignConfiguration.class)
@Api(value = "角色管理", tags = "角色管理")
public interface RoleFeignService {

    /**
     * 根据租户和用户获取角色列表
     */
    @ApiOperation(value = "根据租户和用户获取角色列表")
    @RequestMapping(value = "feignApi/userCenter/role/qryRoleListByUserIdAndApp", method = RequestMethod.POST)
    BaseResult<List<UserRoleInfoResVO>> qryRoleListByUserIdAndApp(@RequestBody SelectUserRoleByAppReqVO vo);


    /**
     * 获取某租户下的全量角色列表
     *
     * @param vo
     * @return
     */
    @ApiOperation(value = "获取某租户下的全量角色列表")
    @RequestMapping(value = "feignApi/userCenter/role/qryRoleListByApp", method = RequestMethod.POST)
    BaseResult<List<RoleInfoResVO>> qryRoleListByApp(@RequestBody FeignSelectRoleListByAppReqVO vo);

    /**
     * 根据用户获取⻆⾊列表（过时）
     *
     * @param vo 用户标识
     * @return 角色列表
     */
    @Deprecated
    @RequestMapping(value = "feignApi/userCenter/role/qryRoleListByUserId", method = RequestMethod.POST)
    @ApiOperation(value = "根据用户获取⻆⾊列表（过时）")
    BaseResult<List<UserRoleInfoResVO>> qryRoleListByUserId(@RequestBody SelectUserRoleReqVO vo);

    /**
     * 根据⻆⾊id获取⽤户列表
     *
     * @param vo 角色标识
     * @return 用户列表
     */
    @ApiOperation(value = "根据⻆⾊id获取⽤户列表" ,notes = "仅查询有效数据")
    @RequestMapping(value = "feignApi/userCenter/role/qryUserListByRoleId", method = RequestMethod.POST)
    BaseResult<List<RoleUserInfoResVO>> qryUserListByRoleId(@RequestBody SelectRoleUserReqVO vo);

    /**
     * 根据⻆⾊id获取⽤户列表
     *
     * @param vo 角色标识
     * @return 用户列表
     */
    @ApiOperation(value = "根据⻆⾊id获取⽤户列表" ,notes = "支持全量或有效查询")
    @RequestMapping(value = "feignApi/userCenter/role/qryUserListWithIsDeletedByRoleId", method = RequestMethod.POST)
    BaseResult<List<RoleUserInfoResVO>> qryUserListWithIsDeletedByRoleId(@RequestBody SelectRoleUserReqVO vo);
    /**
     * 根据⻆⾊id获取⽤户列表附带组织信息
     *
     * @param vo 角色标识
     * @return 用户列表
     */
    @ApiOperation(value = "根据⻆⾊id获取⽤户列表附带组织信息")
    @RequestMapping(value = "feignApi/userCenter/role/qryUserListWithOrgsByRoleId", method = RequestMethod.POST)
    BaseResult<List<RoleUserInfoResVO>> qryUserListWithOrgsByRoleId(@RequestBody SelectRoleUserReqVO vo);

    /**
     * 根据⻆⾊、组织集合获取⽤户列表附带组织信息
     *
     * @param vo 角色标识
     * @return 用户列表
     */
    @ApiOperation(value = "根据⻆⾊、组织集合获取⽤户列表附带组织信息")
    @RequestMapping(value = "feignApi/userCenter/role/qryUserListWithOrgByRoleAndOrg", method = RequestMethod.POST)
    BaseResult<List<RoleUserInfoResVO>> qryUserListWithOrgByRoleAndOrg(@RequestBody SelectRoleUserReqVO vo);

    @ApiOperation(value = "根据⻆⾊、组织集合获取⽤户列表附带组织列表信息")
    @RequestMapping(value = "feignApi/userCenter/role/qryUserListWithOrgsByCondition", method = RequestMethod.POST)
    BaseResult<List<RoleUserInfoResVO>> qryUserListWithOrgsByCondition(@RequestBody SelectRoleUserReqVO vo);
    /**
     * 根据角色
     * @param vo
     * @return
     */
    @Deprecated
    @ApiOperation(value = "根据⻆⾊id获取⽤户列表附带主组织信息", notes = "接口方法弃用")
    @RequestMapping(value = "feignApi/userCenter/role/qryUserListWithPrimaryOrgByRoleId", method = RequestMethod.POST)
    BaseResult<List<RoleUserInfoResVO>> qryUserListWithPrimaryOrgByRoleIdAndOrgIds(@RequestBody SelectRoleUserReqVO vo);

    /**
     * 获取全量角色列表（过时）
     *
     * @return 角色列表
     */
    @Deprecated
    @ApiOperation("获取全量角色列表(过时)")
    @RequestMapping(value = "feignApi/userCenter/role/qryRoleList", method = RequestMethod.POST)
    BaseResult<List<RoleInfoResVO>> qryRoleList();

    /**
     * 分页查询角色
     *
     * @param vo
     * @return
     */
    @ApiOperation(value = "分页查询角色")
    @RequestMapping(value = "feignApi/userCenter/role/selectPage", method = RequestMethod.POST)
    BaseResult<PagerEntity<FeignRoleListResponseVO>> selectPage(@RequestBody FeignSelectRoleListRequestVO vo);

    @ApiOperation(value = "分页查询角色", notes = "支持全量或有效查询，默认为全量")
    @RequestMapping(value = "feignApi/userCenter/role/selectPageWithIsDeleted", method = RequestMethod.POST)
    BaseResult<PagerEntity<FeignRoleListResponseVO>> selectPageWithIsDeleted(@RequestBody FeignSelectRoleListRequestVO vo);
    /**
     * 根据⻆⾊id或者编码获取⽤户列表
     * @param vo
     * @return
     */
    @ApiOperation(value = "根据⻆⾊id或者编码获取⽤户列表",tags = "根据⻆⾊id或者编码获取⽤户列表", notes="仅查询有效数据")
    @RequestMapping(value = "feignApi/userCenter/role/qryUserListByRole", method = RequestMethod.POST)
    BaseResult<List<UserInfoResVO>> qryUserListByRole(@RequestBody GetRoleUserReqVO vo);

    /**
     * 根据⻆⾊id或者编码获取⽤户列表，支持全量查询
     * @param vo
     * @return
     */
    @ApiOperation(value = "根据⻆⾊id或者编码获取⽤户列表",tags = "根据⻆⾊id或者编码获取⽤户列表", notes = "空字符串或Null获取全量数据，Y-只获取有效数据")
    @RequestMapping(value = "feignApi/userCenter/role/qryUserListWithIsDeletedByRole", method = RequestMethod.POST)
    BaseResult<List<UserInfoResVO>> qryUserListWithIsDeletedByRole(@RequestBody GetRoleUserReqVO vo);
    /**
     * 通过多个角色ID查询用户信息列表
     *
     * @param vo 角色标识
     * @return 用户列表
     */
    @ApiOperation(value = "通过多个角色ID查询用户信息列表")
    @RequestMapping(value = "feignApi/userCenter/role/selectUserListByRoleIdListOrAppCodeList", method = RequestMethod.POST)
    BaseResult<List<RpcUserInfoVO>> selectUserListByRoleIdListOrAppCodeList(@RequestBody SelectUserListByRoleIdListReqVO vo);

    /**
     * 通过组织ID/编码，查询其下（包含所有下级组织）所有角色列表
     *
     * @param vo
     * @return
     */
    @ApiOperation(value = "根据组织id或编码分页查询角色")
    @RequestMapping(value = "feignApi/userCenter/role/selectRolePageByOrgCondition", method = RequestMethod.POST)
    BaseResult<PagerEntity<RoleListResponseVO>> selectRolePageByOrgCondition(@RequestBody SelectRoleByOrgVO vo);


     /***
     * 根据用户信息查询角色列表
     *
     * @param vo 用户信息
     * @return 角色列表
     */
    @RequestMapping(value = "feignApi/userCenter/role/selectRoleListByUser", method = RequestMethod.POST)
    @ApiOperation(value = "根据用户信息获取⻆⾊列表")
    BaseResult<PagerEntity<RoleInfoResponseVO>> selectRoleListByUser(@RequestBody SelectRoleListByUserReqVO vo);

    /**
     * 通过组织标识列表查询对应的组织名映射关系
     *
     * @param vo 组织标识列表
     * @return 组织映射关系
     */
    @ApiOperation(value = "通过角色ID列表查询对应的角色名映射关系", notes = "仅支持全量查询")
    @RequestMapping(value = "feignApi/userCenter/role/qryRoleNameMap", method = RequestMethod.POST)
    BaseResult<Map<Long, String>> qryRoleNameMap(@RequestBody List<Long> vo);

    @ApiOperation(value = "根据⻆⾊条件分页查询⽤户列表")
    @RequestMapping(value = "feignApi/userCenter/user/selectUserPageByRoleCondition", method = RequestMethod.POST)
    BaseResult<PagerEntity<UserRoleInfoResVO>> selectUserPageByRoleCondition(@RequestBody SelectUserListByRoleReqVO vo);

    @ApiOperation(value = "通过角色Id或Code查询角色基本信息")
    @RequestMapping(value = "feignApi/userCenter/role/getRoleBaseInfoByIdOrCode", method = RequestMethod.POST)
    BaseResult<RoleBaseInfoResponseVO> getRoleBaseInfoByIdOrCode(@RequestBody GetRoleBaseInfoReqVO paramVO);

    @ApiOperation(value = "根据角色Code员工工号租户Code判断是否有该角色")
    @RequestMapping(value = "feignApi/userCenter/role/checkRoleByCodeAndEmployee", method = RequestMethod.POST)
    BaseResult<List<CheckRoleInfoResponseVO>> checkRoleByCodeAndEmployee(@RequestBody RoleEmployeeReqVO paramVO);


    @ApiOperation(value = "根据角色id为角色授权用户（FRR定制化导入功能）")
    @RequestMapping(value = "feignApi/userCenter/role/insertUserByRoleId", method = RequestMethod.POST)
    BaseResult insertUserByRoleId(@RequestBody UpdateRoleVO updateRoleVO);


}
